package gc;

/*

-XX:NewSize=5242880 -XX:MaxNewSize=5242880 -XX:InitialHeapSize=10485760 -XX:MaxHeapSize=10485760 -XX:SurvivorRatio=8 -XX:PretenureSizeThreshold=10485760 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:gc.log

日志：
Java HotSpot(TM) 64-Bit Server VM (25.221-b11) for windows-amd64 JRE (1.8.0_221-b11), built on Jul  4 2019 04:39:29 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 16637024k(6110952k free), swap 19580420k(2905932k free)
CommandLine flags: -XX:InitialHeapSize=10485760 -XX:MaxHeapSize=10485760 -XX:MaxNewSize=5242880 -XX:NewSize=5242880 -XX:OldPLABSize=16 -XX:PretenureSizeThreshold=10485760 -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:SurvivorRatio=8 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:-UseLargePagesIndividualAllocation -XX:+UseParNewGC
0.200: [GC (Allocation Failure) 0.201: [ParNew: 3975K->512K(4608K), 0.0013221 secs] 3975K->1695K(9728K), 0.0014888 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
0.202: [GC (Allocation Failure) 0.202: [ParNew: 2637K->0K(4608K), 0.0009916 secs] 3820K->1694K(9728K), 0.0010324 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
Heap
 par new generation   total 4608K, used 2089K [0x00000000ff600000, 0x00000000ffb00000, 0x00000000ffb00000)
  eden space 4096K,  51% used [0x00000000ff600000, 0x00000000ff80a558, 0x00000000ffa00000)
  from space 512K,   0% used [0x00000000ffa00000, 0x00000000ffa00000, 0x00000000ffa80000)
  to   space 512K,   0% used [0x00000000ffa80000, 0x00000000ffa80000, 0x00000000ffb00000)
 concurrent mark-sweep generation total 5120K, used 1694K [0x00000000ffb00000, 0x0000000100000000, 0x0000000100000000)
 Metaspace       used 3229K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 350K, capacity 388K, committed 512K, reserved 1048576K

 */

/**
 * @author eii
 * @sice 2020/12/15
 */
public class Demo1 {
    public static void main(String[] args) {
        byte[] array = new byte[1024 * 1024];
        array = new byte[1024 * 1024];
        array = new byte[1024 * 1024];
        array = new byte[1024 * 1024];
        array = null;
        byte[] array2 = new byte[2 * 1024 * 1024];
    }
}
